#include "background.h"

extern u8 wallTexture_png[];

Background::Background()
{
	_bgImage = new Image();
	
	if(_bgImage->LoadImage(wallTexture_png, IMG_LOAD_TYPE_BUFFER) != IMG_LOAD_ERROR_NONE)exit(0);
	
	_bgSprite.SetImage(_bgImage);
	_bgSprite.SetPosition(0,0);
	
}

Background::~Background()
{

}

void Background::Render(float tDx, float tDy)
{
/*	float dx = abs(tDx) % 640;
	float dy = abs(tDy) % 480;
	
	if(tDx < 0) dx *= -1;
	
	if(tDy < 0) dy *= -1;
	
	_bgSprite.SetPosition(dx,dy);
	_bgSprite.Draw();
	
	if(dx > 0)
	{
		_bgSprite.SetPosition(dx - 640, dy);
		_bgSprite.Draw();
		
		if(dy > 0)
		{
			_bgSprite.SetPosition(dx-640, dy-480);
			_bgSprite.Draw();
                        _bgSprite.SetPosition(dx,dy-480);
                        _bgSprite.Draw();
		}
		else if(dy < 0)
		{
			_bgSprite.SetPosition(dx-640, dy+480);
			_bgSprite.Draw();
                        _bgSprite.SetPosition(dx,dy+480);
                        _bgSprite.Draw();
		}
                else
                {
			_bgSprite.SetPosition(dx-640, dy+480);
			_bgSprite.Draw();
                        _bgSprite.SetPosition(dx-640,dy-480);
                        _bgSprite.Draw();
                }
	}
	else if(dx < 0)
	{
		_bgSprite.SetPosition(dx + 640, dy);
		_bgSprite.Draw();
		
		if(dy > 0)
		{
			_bgSprite.SetPosition(dx+640, dy-480);
			_bgSprite.Draw();
                        _bgSprite.SetPosition(dx,dy-480);
                        _bgSprite.Draw();
		}else if(dy < 0)
		{
			_bgSprite.SetPosition(dx+640, dy+480);
			_bgSprite.Draw();
                        _bgSprite.SetPosition(dx,dy+480);
                        _bgSprite.Draw();
		}
                else
                {
			_bgSprite.SetPosition(dx+640, dy+480);
			_bgSprite.Draw();
                        _bgSprite.SetPosition(dx+640,dy-480);
                        _bgSprite.Draw();
                }
	}
        else
        {
			_bgSprite.SetPosition(dx, dy-480);
			_bgSprite.Draw();
                        _bgSprite.SetPosition(dx,dy+480);
                        _bgSprite.Draw();
        }
		Quad bar;
		bar.SetFillColor((GXColor){100,100,100,255});
		bar.SetPosition(0, 0);
		bar.SetHeight(480);
		bar.SetWidth(640);
		bar.Draw();
*/
}

